home *** CD-ROM | disk | FTP | other *** search
- package javax.management;
-
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.security.Permission;
-
- public class MBeanPermission extends Permission {
- private static final long serialVersionUID = -2416928705275160661L;
- private static final int AddNotificationListener = 1;
- private static final int GetAttribute = 2;
- private static final int GetClassLoader = 4;
- private static final int GetClassLoaderFor = 8;
- private static final int GetClassLoaderRepository = 16;
- private static final int GetDomains = 32;
- private static final int GetMBeanInfo = 64;
- private static final int GetObjectInstance = 128;
- private static final int Instantiate = 256;
- private static final int Invoke = 512;
- private static final int IsInstanceOf = 1024;
- private static final int QueryMBeans = 2048;
- private static final int QueryNames = 4096;
- private static final int RegisterMBean = 8192;
- private static final int RemoveNotificationListener = 16384;
- private static final int SetAttribute = 32768;
- private static final int UnregisterMBean = 65536;
- private static final int NONE = 0;
- private static final int ALL = 131071;
- private String actions;
- private transient int mask;
- private transient String classNamePrefix;
- private transient boolean classNameExactMatch;
- private transient String member;
- private transient ObjectName objectName;
-
- private void parseActions() {
- if (this.actions == null) {
- throw new IllegalArgumentException("MBeanPermission: actions can't be null");
- } else if (this.actions.equals("")) {
- throw new IllegalArgumentException("MBeanPermission: actions can't be empty");
- } else {
- int var1 = getMask(this.actions);
- if ((var1 & 131071) != var1) {
- throw new IllegalArgumentException("Invalid actions mask");
- } else if (var1 == 0) {
- throw new IllegalArgumentException("Invalid actions mask");
- } else {
- this.mask = var1;
- }
- }
- }
-
- private void parseName() {
- String var1 = this.getName();
- if (var1 == null) {
- throw new IllegalArgumentException("MBeanPermission name cannot be null");
- } else if (var1.equals("")) {
- throw new IllegalArgumentException("MBeanPermission name cannot be empty");
- } else {
- int var2 = var1.indexOf("[");
- if (var2 == -1) {
- this.objectName = ObjectName.WILDCARD;
- } else {
- if (!var1.endsWith("]")) {
- throw new IllegalArgumentException("MBeanPermission: The ObjectName in the target name must be included in square brackets");
- }
-
- try {
- String var3 = var1.substring(var2 + 1, var1.length() - 1);
- if (var3.equals("")) {
- this.objectName = ObjectName.WILDCARD;
- } else if (var3.equals("-")) {
- this.objectName = null;
- } else {
- this.objectName = new ObjectName(var3);
- }
- } catch (MalformedObjectNameException var5) {
- throw new IllegalArgumentException("MBeanPermission: The target name does not specify a valid ObjectName");
- }
-
- var1 = var1.substring(0, var2);
- }
-
- int var6 = var1.indexOf("#");
- if (var6 == -1) {
- this.setMember("*");
- } else {
- String var4 = var1.substring(var6 + 1);
- this.setMember(var4);
- var1 = var1.substring(0, var6);
- }
-
- this.setClassName(var1);
- }
- }
-
- private void initName(String var1, String var2, ObjectName var3) {
- this.setClassName(var1);
- this.setMember(var2);
- this.objectName = var3;
- }
-
- private void setClassName(String var1) {
- if (var1 != null && !var1.equals("-")) {
- if (!var1.equals("") && !var1.equals("*")) {
- if (var1.endsWith(".*")) {
- this.classNamePrefix = var1.substring(0, var1.length() - 1);
- this.classNameExactMatch = false;
- } else {
- this.classNamePrefix = var1;
- this.classNameExactMatch = true;
- }
- } else {
- this.classNamePrefix = "";
- this.classNameExactMatch = false;
- }
- } else {
- this.classNamePrefix = null;
- this.classNameExactMatch = false;
- }
-
- }
-
- private void setMember(String var1) {
- if (var1 != null && !var1.equals("-")) {
- if (var1.equals("")) {
- this.member = "*";
- } else {
- this.member = var1;
- }
- } else {
- this.member = null;
- }
-
- }
-
- public MBeanPermission(String var1, String var2) {
- super(var1);
- this.parseName();
- this.actions = var2;
- this.parseActions();
- }
-
- public MBeanPermission(String var1, String var2, ObjectName var3, String var4) {
- super(makeName(var1, var2, var3));
- this.initName(var1, var2, var3);
- this.actions = var4;
- this.parseActions();
- }
-
- private static String makeName(String var0, String var1, ObjectName var2) {
- StringBuffer var3 = new StringBuffer();
- if (var0 == null) {
- var0 = "-";
- }
-
- var3.append(var0);
- if (var1 == null) {
- var1 = "-";
- }
-
- var3.append("#" + var1);
- if (var2 == null) {
- var3.append("[-]");
- } else {
- var3.append("[").append(var2.getCanonicalName()).append("]");
- }
-
- return var3.length() == 0 ? "*" : var3.toString();
- }
-
- public String getActions() {
- if (this.actions == null) {
- this.actions = getActions(this.mask);
- }
-
- return this.actions;
- }
-
- private static String getActions(int var0) {
- StringBuffer var1 = new StringBuffer();
- boolean var2 = false;
- if ((var0 & 1) == 1) {
- var2 = true;
- var1.append("addNotificationListener");
- }
-
- if ((var0 & 2) == 2) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getAttribute");
- }
-
- if ((var0 & 4) == 4) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getClassLoader");
- }
-
- if ((var0 & 8) == 8) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getClassLoaderFor");
- }
-
- if ((var0 & 16) == 16) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getClassLoaderRepository");
- }
-
- if ((var0 & 32) == 32) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getDomains");
- }
-
- if ((var0 & 64) == 64) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getMBeanInfo");
- }
-
- if ((var0 & 128) == 128) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("getObjectInstance");
- }
-
- if ((var0 & 256) == 256) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("instantiate");
- }
-
- if ((var0 & 512) == 512) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("invoke");
- }
-
- if ((var0 & 1024) == 1024) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("isInstanceOf");
- }
-
- if ((var0 & 2048) == 2048) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("queryMBeans");
- }
-
- if ((var0 & 4096) == 4096) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("queryNames");
- }
-
- if ((var0 & 8192) == 8192) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("registerMBean");
- }
-
- if ((var0 & 16384) == 16384) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("removeNotificationListener");
- }
-
- if ((var0 & 'ËÄÄ') == 32768) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("setAttribute");
- }
-
- if ((var0 & 65536) == 65536) {
- if (var2) {
- var1.append(',');
- } else {
- var2 = true;
- }
-
- var1.append("unregisterMBean");
- }
-
- return var1.toString();
- }
-
- public int hashCode() {
- return this.getName().hashCode() + this.getActions().hashCode();
- }
-
- private static int getMask(String param0) {
- // $FF: Couldn't be decompiled
- }
-
- public boolean implies(Permission var1) {
- if (!(var1 instanceof MBeanPermission)) {
- return false;
- } else {
- MBeanPermission var2 = (MBeanPermission)var1;
- if ((this.mask & 2048) == 2048) {
- if (((this.mask | 4096) & var2.mask) != var2.mask) {
- return false;
- }
- } else if ((this.mask & var2.mask) != var2.mask) {
- return false;
- }
-
- if (var2.classNamePrefix != null) {
- if (this.classNamePrefix == null) {
- return false;
- }
-
- if (this.classNameExactMatch) {
- if (!var2.classNameExactMatch) {
- return false;
- }
-
- if (!var2.classNamePrefix.equals(this.classNamePrefix)) {
- return false;
- }
- } else if (!var2.classNamePrefix.startsWith(this.classNamePrefix)) {
- return false;
- }
- }
-
- if (var2.member != null) {
- if (this.member == null) {
- return false;
- }
-
- if (!this.member.equals("*") && !this.member.equals(var2.member)) {
- return false;
- }
- }
-
- if (var2.objectName != null) {
- if (this.objectName == null) {
- return false;
- }
-
- if (!this.objectName.apply(var2.objectName) && !this.objectName.equals(var2.objectName)) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- public boolean equals(Object var1) {
- if (var1 == this) {
- return true;
- } else if (!(var1 instanceof MBeanPermission)) {
- return false;
- } else {
- MBeanPermission var2 = (MBeanPermission)var1;
- return this.mask == var2.mask && this.getName().equals(var2.getName());
- }
- }
-
- private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- this.parseName();
- this.parseActions();
- }
- }
-